package yxy.game.pm2.bean.module;

import yxy.game.pm2.bean.PlayerBean;
import yxy.game.pm2.bean.ServerBean;
import yxy.game.pm2.bean.area.AreaBean;
import yxy.game.pm2.bean.timeline.TimelineModule;

/** 服务器模块 */
public abstract class AreaModule extends TimelineModule {

	private int areaId;

	public AreaModule() {
		super();
	}

	public int getAreaId() {
		return areaId;
	}

	public void setAreaId(int areaId) {
		this.areaId = areaId;
	}

	static protected String key(int areaId, String moduleName) {
		return String.format("AREA:%s:MODULE:%s", areaId, moduleName);
	}

	static public AreaBean area(String playerCode) {
		PlayerBean playerBean = PlayerBean.get(playerCode);
		return area(playerBean);
	}

	static public AreaBean area(PlayerBean playerBean) {
		try {
			ServerBean serverBean = ServerBean.get(playerBean.getServerId());
			AreaBean areaBean = AreaBean.get(serverBean.getAreaId());
			return areaBean;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
